#!/usr/bin/bash
#
#  Usage: docker compose stop
#  Issue: 2024-05-14
# Author: Leon Hsia
#   Mail: waxwork3@163.com
#
if ! which realpath >/dev/null 2>&1; then
    echo "can't find command which is needed."
    exit 1
fi

base_path=$(dirname $(realpath $0))
cd $base_path

if [ ${#base_path} -le 4 ]; then
    echo "path too short."
    exit 1
fi

which docker-compose >/dev/null 2>&1 || docker compose down
which docker-compose >/dev/null 2>&1 && docker-compose down
sleep 1
width=$(stty size |awk '{print $2}')
for ((i=1; i<=$width; i++)); do printf "%c" "#"; done
docker ps 
